<!DOCTYPE html>
<html>
<?php $this->load->view('admin/public/header.html');?>

<body class="childrenBody">
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form" style="display: flex">
            <div class="layui-inline">
                <div class="layui-input-inline" style="display:flex; ">
                    <input type="text" class="layui-input searchVal1" placeholder="请输入订单标题" style="display: block; width: 140px;margin-right: 10px;"/>
                    <input type="text" class="layui-input searchVal2" placeholder="请输入订单编号"  style="display: block; width: 140px;margin-right: 10px;" />
                    <input type="text" class="layui-input searchVal3" placeholder="请输入用户姓名"  style="display: block; width: 140px;margin-right: 10px;" />
                    <input type="text" class="layui-input searchVal4" placeholder="请输入技师服务编号"  style="display: block; width: 140px;margin-right: 10px;" />
                    <div class="layui-form-item magt">
                        <label class="layui-form-label">订单状态</label>
                        <div class="layui-input-block" style="width: 140px">
                            <select name="status" class="searchVal5" lay-verify="require" lay-search >
                                <option value="">请选择订单状态</option>
                                <option value="1">未付款</option>
                                <option value="2">已付款未使用</option>
                                <option value="3">已使用未评价</option>
                                <option value="4">已评价</option>
                            </select>
                        </div>
                    </div>
                    <a class="layui-btn search_btn" data-type="reload" style="display: block;margin-left: 30px; ">搜索</a>
                </div>
            </div>
        </form>
    </blockquote>



    <table id="newsList" lay-filter="newsList" style="width: 100%; height: 100%"></table>


    <!--操作-->
    <script type="text/html" id="newsListBar">
        <a class="layui-btn layui-btn-xs"  lay-event="check">查看详情</a>
    </script>
</form>
<script type="text/javascript">

    layui.use(['form','layer','laydate','table','laytpl'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laydate = layui.laydate,
            laytpl = layui.laytpl,
            table = layui.table,
            page;
        //列表
        var tableIns = table.render({
            elem: '#newsList',
            url : '<?php echo site_url("seller/order/getTechnicianList")?>',
            cellMinWidth : 95,
            page : true,
            height : "full-125",
            limit : 20,
            limits : [10,15,20,25],

            id : "newsListTable",
            cols : [[
                {field: 'orderId', title: 'ID', width:50, align:"center",sort:true},
                {field: 'payTitle', title: '订单标题'},
                {field: 'trade_no', title: '交易单号/订单编号'},
                {field: 'realName', title: '用户姓名'},
                {field: 'sevriceNo', title: '技师服务编号'},
                {field: 'status', title: '状态'},
                {field: 'createTime', title: '创建时间'},

                {title: '操作',width:100, field:'tools', templet:'#newsListBar',fixed:"right",align:"center"}
            ]],
            response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                ,statusCode: 200 //成功的状态码，默认：0
                ,msgName: 'msg' //状态信息的字段名称，默认：msg
                ,countName: 'count' //数据总数的字段名称，默认：count
                ,dataName: 'data' //数据列表的字段名称，默认：data
            } ,
            done:function(res,curr,count){
                page=curr;
            }
        });

        //搜索
        $(".search_btn").on("click",function(){
            table.reload("newsListTable",{
                page: {
                    curr: 1 //重新从第 1 页开始
                },
                where: {
                    payTitle: $(".searchVal1").val(),  //订单标题
                    trade_no: $(".searchVal2").val(),  //订单编号
                    realName: $(".searchVal3").val(),  //用户姓名
                    sevriceNo: $(".searchVal4").val(), //技师服务编号
                    status: $(".searchVal5").val() //技师服务编号
                }
            })
        });

        function addNews(edit){
            var index = layui.layer.open({
                title : "用户信息",
                type : 2,
                content : "<?php echo site_url('seller/order/add')?>",		//iframe层时,这个参数传URL
                success : function(layero, index){
                    var body = layui.layer.getChildFrame('body', index);
                    if(edit){
                        body.find("[name=orderId]").val(edit.orderId);
                        body.find("[name=payTitle]").val(edit.payTitle);
                        body.find('[name=trade_no]').val(edit.trade_no);
                        body.find('[name=realName]').val(edit.realName);
                        body.find('[name=title]').val(edit.title);
                        body.find('[name=phone]').val(edit.phone);
                        body.find('[name=technicianName]').val(edit.technicianName);
                        body.find('[name=sevriceNo]').val(edit.sevriceNo);
                        body.find('[name=typeFlag]').val(edit.typeFlag);
                        body.find('[name=status]').val(edit.status);
                        body.find('[name=price]').val(edit.price);
                        body.find('[name=num]').val(edit.num);
                        body.find('[name=totalPrice]').val(edit.totalPrice);
                        body.find('[name=createTime]').val(edit.createTime);
                        body.find('[name=updateTime]').val(edit.updateTime);

                        form.render();

                    }

                    setTimeout(function(){
                        layui.layer.tips('点击返回', '.layui-layer-setwin .layui-layer-close', {
                            tips: 3
                        });
                    },500)
                }
            })
            layui.layer.full(index);
            //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
            $(window).on("resize",function(){
                layui.layer.full(index);
            })
        }

        $(".addNews_btn").click(function(){
            addNews();
        })
        table.on('tool(newsList)', function(obj){
            console.log(obj)
            var layEvent = obj.event,
                data = obj.data;		//用户数据
            if(layEvent === 'check'){ //编辑
                addNews(data);
            }
        });

    })

</script>
</body>
</html>